package com.leucoderma.medicine.controller;

import com.leucoderma.medicine.pojo.Patient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.ModelAndView;

@Slf4j
@Controller
public class PageController {
    @RequestMapping("/{moduleName}")
    public String defaultPage(@PathVariable String moduleName) {
        System.out.println("默认跳转方法");
        return moduleName;	//经过视图解析器,动态跳转页面
    }
    @RequestMapping(value="/",method= RequestMethod.GET)
    public ModelAndView index(){
        ModelAndView modelAndView = new ModelAndView("/index");
        return modelAndView;
    }
    @RequestMapping(value="/bootstrap",method= RequestMethod.GET)
    public ModelAndView bootstrap(){
        ModelAndView modelAndView = new ModelAndView("/bootstrap");
        return modelAndView;
    }
    @RequestMapping(value="/addDrugs",method= RequestMethod.GET)
    public ModelAndView addDrugs(){
        ModelAndView modelAndView = new ModelAndView("/addDrugs");
        return modelAndView;
    }
    @RequestMapping(value="/home",method= RequestMethod.GET)
    public ModelAndView home(){
        ModelAndView modelAndView = new ModelAndView("home");
        return modelAndView;
    }
//    @RequestMapping(value="/save",method= RequestMethod.GET)
//    public ModelAndView save(Patient patient){
//        System.out.println(patient);
//        ModelAndView modelAndView = new ModelAndView("/pages/save");
//        return modelAndView;
//    }
    @RequestMapping(value="/save",method= RequestMethod.GET)
    public ModelAndView save(String name, String recordNo){
        ModelAndView modelAndView = new ModelAndView("/save");
        modelAndView.addObject("name",name);
        modelAndView.addObject("recordNo",recordNo);
        return modelAndView;
    }
}
